
/*
'===============================================================================
'  Generated From - CSharp_dOOdads_BusinessEntity.vbgen
' 
'  ** IMPORTANT  ** 
'  How to Generate your stored procedures:
' 
'  SQL      = SQL_StoredProcs.vbgen
'  ACCESS   = Access_StoredProcs.vbgen
'  ORACLE   = Oracle_StoredProcs.vbgen
'  FIREBIRD = FirebirdStoredProcs.vbgen
'
'  The supporting base class FirebirdSqlEntity is in the Architecture directory in "dOOdads".
'  
'  This object is 'abstract' which means you need to inherit from it to be able
'  to instantiate it.  This is very easilly done. You can override properties and
'  methods in your derived class, this allows you to regenerate this class at any
'  time and not worry about overwriting custom code. 
'
'  NEVER EDIT THIS FILE.
'
'  public class YourObject :  _YourObject
'  {
'
'  }
'
'===============================================================================
*/

// Generated by MyGeneration Version # (1.0.0.4)

using System;
using System.Data;
using FirebirdSql.Data.Firebird;
using System.Collections;
using System.Collections.Specialized;

using MyGeneration.dOOdads;

namespace CSharp.FIREBIRD.DIALECT3_TRUE
{
	public abstract class _Employees : FirebirdSqlEntity
	{
		public _Employees()
		{
			this.QuerySource = "Employees";
			this.MappingName = "Employees";
			this.Dialect = 3;

		}	

		//=================================================================
		//  public Overrides void AddNew()
		//=================================================================
		//
		//=================================================================
		public override void AddNew()
		{
			base.AddNew();
			
		}
		
		
		public override void FlushData()
		{
			this._whereClause = null;
			base.FlushData();
		}
		
		//=================================================================
		//  	public Function LoadAll() As Boolean
		//=================================================================
		//  Loads all of the records in the database, and sets the currentRow to the first row
		//=================================================================
		public bool LoadAll() 
		{
			ListDictionary parameters = null;
			
			return base.LoadFromSql("PL_EMPLOYEES", parameters);
		}
	
		//=================================================================
		// public Overridable Function LoadByPrimaryKey()  As Boolean
		//=================================================================
		//  Loads a single row of via the primary key
		//=================================================================
		public virtual bool LoadByPrimaryKey(long EmployeeID)
		{
			ListDictionary parameters = new ListDictionary();
			parameters.Add(Parameters.EmployeeID, EmployeeID);

		
			return base.LoadFromSql("PK_EMPLOYEES", parameters);
		}
		
		#region Parameters
		protected class Parameters
		{
			
			public static FbParameter EmployeeID
			{
				get
				{
					return new FbParameter("@EmployeeID", FbDbType.BigInt, 0);
				}
			}
			
			public static FbParameter FirstName
			{
				get
				{
					return new FbParameter("@FirstName", FbDbType.VarChar, 80);
				}
			}
			
			public static FbParameter LastName
			{
				get
				{
					return new FbParameter("@LastName", FbDbType.VarChar, 80);
				}
			}
			
		}
		#endregion		
	
		#region ColumnNames
		public class ColumnNames
		{  
			public const string EmployeeID = "EmployeeID";
			public const string FirstName = "FirstName";
			public const string LastName = "LastName";

			static public string ToPropertyName(string columnName)
			{
				if(ht == null)
				{
					ht = new Hashtable();
					
					ht[EmployeeID] = _Employees.PropertyNames.EmployeeID;
					ht[FirstName] = _Employees.PropertyNames.FirstName;
					ht[LastName] = _Employees.PropertyNames.LastName;

				}
				return (string)ht[columnName];
			}

			static private Hashtable ht = null;			 
		}
		#endregion
		
		#region PropertyNames
		public class PropertyNames
		{  
			public const string EmployeeID = "EmployeeID";
			public const string FirstName = "FirstName";
			public const string LastName = "LastName";

			static public string ToColumnName(string propertyName)
			{
				if(ht == null)
				{
					ht = new Hashtable();
					
					ht[EmployeeID] = _Employees.ColumnNames.EmployeeID;
					ht[FirstName] = _Employees.ColumnNames.FirstName;
					ht[LastName] = _Employees.ColumnNames.LastName;

				}
				return (string)ht[propertyName];
			}

			static private Hashtable ht = null;			 
		}			 
		#endregion	

		#region StringPropertyNames
		public class StringPropertyNames
		{  
			public const string EmployeeID = "s_EmployeeID";
			public const string FirstName = "s_FirstName";
			public const string LastName = "s_LastName";

		}
		#endregion		
		
		#region Properties
	
		public virtual long EmployeeID
		{
			get
			{
				return base.Getlong(ColumnNames.EmployeeID);
			}
			set
			{
				base.Setlong(ColumnNames.EmployeeID, value);
			}
		}

		public virtual string FirstName
		{
			get
			{
				return base.Getstring(ColumnNames.FirstName);
			}
			set
			{
				base.Setstring(ColumnNames.FirstName, value);
			}
		}

		public virtual string LastName
		{
			get
			{
				return base.Getstring(ColumnNames.LastName);
			}
			set
			{
				base.Setstring(ColumnNames.LastName, value);
			}
		}


		#endregion
		
		#region String Properties
	
		public virtual string s_EmployeeID
		{
			get
			{
				return this.IsColumnNull(ColumnNames.EmployeeID) ? string.Empty : base.GetlongAsString(ColumnNames.EmployeeID);
			}
			set
			{
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.EmployeeID);
				else
					this.EmployeeID = base.SetlongAsString(ColumnNames.EmployeeID, value);
			}
		}

		public virtual string s_FirstName
		{
			get
			{
				return this.IsColumnNull(ColumnNames.FirstName) ? string.Empty : base.GetstringAsString(ColumnNames.FirstName);
			}
			set
			{
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.FirstName);
				else
					this.FirstName = base.SetstringAsString(ColumnNames.FirstName, value);
			}
		}

		public virtual string s_LastName
		{
			get
			{
				return this.IsColumnNull(ColumnNames.LastName) ? string.Empty : base.GetstringAsString(ColumnNames.LastName);
			}
			set
			{
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.LastName);
				else
					this.LastName = base.SetstringAsString(ColumnNames.LastName, value);
			}
		}


		#endregion		
	
		#region Where Clause
		public class WhereClause
		{
			public WhereClause(BusinessEntity entity)
			{
				this._entity = entity;
			}
			
			public TearOffWhereParameter TearOff
			{
				get
				{
					if(_tearOff == null)
					{
						_tearOff = new TearOffWhereParameter(this);
					}

					return _tearOff;
				}
			}

			#region TearOff's
			public class TearOffWhereParameter
			{
				public TearOffWhereParameter(WhereClause clause)
				{
					this._clause = clause;
				}
				
				
				public WhereParameter EmployeeID
				{
					get
					{
						WhereParameter where = new WhereParameter(ColumnNames.EmployeeID, Parameters.EmployeeID);
						this._clause._entity.Query.AddWhereParameter(where);
						return where;
					}
				}

				public WhereParameter FirstName
				{
					get
					{
						WhereParameter where = new WhereParameter(ColumnNames.FirstName, Parameters.FirstName);
						this._clause._entity.Query.AddWhereParameter(where);
						return where;
					}
				}

				public WhereParameter LastName
				{
					get
					{
						WhereParameter where = new WhereParameter(ColumnNames.LastName, Parameters.LastName);
						this._clause._entity.Query.AddWhereParameter(where);
						return where;
					}
				}


				private WhereClause _clause;
			}
			#endregion
		
			public WhereParameter EmployeeID
			{
				get
				{
					if(_EmployeeID_W == null)
					{
						_EmployeeID_W = TearOff.EmployeeID;
					}
					return _EmployeeID_W;
				}
			}

			public WhereParameter FirstName
			{
				get
				{
					if(_FirstName_W == null)
					{
						_FirstName_W = TearOff.FirstName;
					}
					return _FirstName_W;
				}
			}

			public WhereParameter LastName
			{
				get
				{
					if(_LastName_W == null)
					{
						_LastName_W = TearOff.LastName;
					}
					return _LastName_W;
				}
			}

			private WhereParameter _EmployeeID_W = null;
			private WhereParameter _FirstName_W = null;
			private WhereParameter _LastName_W = null;

			public void WhereClauseReset()
			{
				_EmployeeID_W = null;
				_FirstName_W = null;
				_LastName_W = null;

				this._entity.Query.FlushWhereParameters();

			}
	
			private BusinessEntity _entity;
			private TearOffWhereParameter _tearOff;
			
		}
	
		public WhereClause Where
		{
			get
			{
				if(_whereClause == null)
				{
					_whereClause = new WhereClause(this);
				}
		
				return _whereClause;
			}
		}
		
		private WhereClause _whereClause = null;	
		#endregion
	
		protected override IDbCommand GetInsertCommand() 
		{
		
			FbCommand cmd = new FbCommand();
			cmd.CommandType = CommandType.StoredProcedure;
			cmd.CommandText = "EXECUTE PROCEDURE PI_EMPLOYEES (?,?,?)";
	
			CreateParameters(cmd);
			
			FbParameter p;
			p = cmd.Parameters[Parameters.EmployeeID.ParameterName];
			p.Direction = ParameterDirection.InputOutput;
    
			return cmd;
		}
	
		protected override IDbCommand GetUpdateCommand()
		{
		
			FbCommand cmd = new FbCommand();
			cmd.CommandType = CommandType.StoredProcedure;
			cmd.CommandText = "EXECUTE PROCEDURE PU_EMPLOYEES (?,?,?)";
	
			CreateParameters(cmd);
			      
			return cmd;
		}
	
		protected override IDbCommand GetDeleteCommand()
		{
		
			FbCommand cmd = new FbCommand();
			cmd.CommandType = CommandType.StoredProcedure;
			cmd.CommandText = "EXECUTE PROCEDURE PD_EMPLOYEES (?)";
	
			FbParameter p;
			p = cmd.Parameters.Add(Parameters.EmployeeID);
			p.SourceColumn = ColumnNames.EmployeeID;
			p.SourceVersion = DataRowVersion.Current;

  
			return cmd;
		}
		
		private IDbCommand CreateParameters(FbCommand cmd)
		{
			FbParameter p;
		
			p = cmd.Parameters.Add(Parameters.EmployeeID);
			p.SourceColumn = ColumnNames.EmployeeID;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.FirstName);
			p.SourceColumn = ColumnNames.FirstName;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.LastName);
			p.SourceColumn = ColumnNames.LastName;
			p.SourceVersion = DataRowVersion.Current;


			return cmd;
		}
	}
}


